package cn.iocoder.yudao.module.jifenyuan.controller.app.sharecode;

import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.jifenyuan.controller.app.sharecode.vo.*;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.sharecode.ShareCodeDO;
import cn.iocoder.yudao.module.jifenyuan.convert.sharecode.ShareCodeConvert;
import cn.iocoder.yudao.module.jifenyuan.service.sharecode.ShareCodeService;

@Tag(name = "用户 APP - 分享码对应的内容")
@RestController
@RequestMapping("/jifenyuan/share-code")
@Validated
public class AppShareCodeController {

    @Resource
    private ShareCodeService shareCodeService;

//    @PostMapping("/create")
//    @Operation(summary = "创建分享码对应的内容")
//
//    public CommonResult<Long> createShareCode(@Valid @RequestBody AppShareCodeCreateReqVO createReqVO) {
//        return success(shareCodeService.createShareCode(createReqVO));
//    }
//
//    @PutMapping("/update")
//    @Operation(summary = "更新分享码对应的内容")
//
//    public CommonResult<Boolean> updateShareCode(@Valid @RequestBody AppShareCodeUpdateReqVO updateReqVO) {
//        shareCodeService.updateShareCode(updateReqVO);
//        return success(true);
//    }
//
//    @DeleteMapping("/delete")
//    @Operation(summary = "删除分享码对应的内容")
//    @Parameter(name = "id", description = "编号", required = true)
//
//    public CommonResult<Boolean> deleteShareCode(@RequestParam("id") Long id) {
//        shareCodeService.deleteShareCode(id);
//        return success(true);
//    }

    @GetMapping("/get")
    @Operation(summary = "获得分享码对应的内容")
    @Parameter(name = "code", description = "分享码", required = true, example = "1024")
    public CommonResult<AppShareCodeRespVO> getShareCode(@RequestParam("code") String code) {
        ShareCodeDO shareCode = shareCodeService.getShareCode(code);
        return success(ShareCodeConvert.INSTANCE.convert(shareCode));
    }

//    @GetMapping("/list")
//    @Operation(summary = "获得分享码对应的内容列表")
//    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
//
//    public CommonResult<List<AppShareCodeRespVO>> getShareCodeList(@RequestParam("ids") Collection<Long> ids) {
//        List<ShareCodeDO> list = shareCodeService.getShareCodeList(ids);
//        return success(ShareCodeConvert.INSTANCE.convertList(list));
//    }
//
//    @GetMapping("/page")
//    @Operation(summary = "获得分享码对应的内容分页")
//
//    public CommonResult<PageResult<AppShareCodeRespVO>> getShareCodePage(@Valid AppShareCodePageReqVO pageVO) {
//        PageResult<ShareCodeDO> pageResult = shareCodeService.getShareCodePage(pageVO);
//        return success(ShareCodeConvert.INSTANCE.convertPage(pageResult));
//    }
//
//    @GetMapping("/export-excel")
//    @Operation(summary = "导出分享码对应的内容 Excel")
//
//    @OperateLog(type = EXPORT)
//    public void exportShareCodeExcel(@Valid AppShareCodeExportReqVO exportReqVO,
//              HttpServletResponse response) throws IOException {
//        List<ShareCodeDO> list = shareCodeService.getShareCodeList(exportReqVO);
//        // 导出 Excel
//        List<AppShareCodeExcelVO> datas = ShareCodeConvert.INSTANCE.convertList02(list);
//        ExcelUtils.write(response, "分享码对应的内容.xls", "数据", AppShareCodeExcelVO.class, datas);
//    }

}
